package com.push.web.controller;

import java.util.Arrays;
import java.util.List;

import com.push.common.utils.StringUtils;
import com.push.web.domain.BizBibAffi;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.push.common.annotation.Log;
import com.push.common.core.controller.BaseController;
import com.push.common.core.domain.AjaxResult;
import com.push.common.enums.BusinessType;
import com.push.web.domain.BizBibExpert;
import com.push.web.service.IBizBibExpertService;
import com.push.common.utils.poi.ExcelUtil;
import com.push.common.core.page.TableDataInfo;

/**
 * 专家Controller
 *
 * @author yanxi
 * @date 2022-10-10
 */
@RestController
@RequestMapping("/intelligence/expert")
public class BizBibExpertController extends BaseController
{
    @Autowired
    private IBizBibExpertService bizBibExpertService;

    /**
     * 查询专家列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizBibExpert bizBibExpert)
    {
        startPage();
        List<BizBibExpert> list = bizBibExpertService.selectBizBibExpertList(bizBibExpert);
        return getDataTable(list);
    }

    /**
     * 导出专家列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:export')")
    @Log(title = "专家", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizBibExpert bizBibExpert)
    {
        List<BizBibExpert> list = bizBibExpertService.selectBizBibExpertList(bizBibExpert);
        ExcelUtil<BizBibExpert> util = new ExcelUtil<BizBibExpert>(BizBibExpert.class);
        return util.exportExcel(list, "专家数据");
    }

    /**
     * 获取专家详细信息
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:query')")
    @GetMapping(value = "/{expId}")
    public AjaxResult getInfo(@PathVariable("expId") String expId)
    {
        return AjaxResult.success(bizBibExpertService.selectBizBibExpertByExpId(expId));
    }

    /**
     * 新增专家
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:add')")
    @Log(title = "专家", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizBibExpert bizBibExpert)
    {
        return toAjax(bizBibExpertService.insertBizBibExpert(bizBibExpert));
    }

    /**
     * 修改专家
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:edit')")
    @Log(title = "专家", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizBibExpert bizBibExpert)
    {
        return toAjax(bizBibExpertService.updateBizBibExpert(bizBibExpert));
    }

    /**
     * 删除专家
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:remove')")
    @Log(title = "专家", businessType = BusinessType.DELETE)
	@DeleteMapping("/{expIds}")
    public AjaxResult remove(@PathVariable String[] expIds)
    {
        return toAjax(bizBibExpertService.deleteBizBibExpertByExpIds(expIds));
    }

    /**
     * 修改标准单位
     */
    @PreAuthorize("@ss.hasPermi('intelligence:expert:doSearch')")
    @Log(title = "数据检索", businessType = BusinessType.OTHER)
    @PostMapping("/doSearch")
    public AjaxResult doSearch(@RequestBody BizBibExpert bizBibExpert)
    {
        if (StringUtils.isNull(bizBibExpert)){
            return AjaxResult.success("启动成功");
        }
        List<String> dbList= Arrays.asList(bizBibExpert.getDbase().split(","));
        if (dbList.contains("万方")){

        }
        System.out.println(bizBibExpert.toString());
        return AjaxResult.success("启动成功");
    }
}
